package com.dsl.tms.controller;

import com.dsl.tms.entity.request.AdminInfo;
import com.dsl.tms.entity.response.AdminTokenMap;
import com.dsl.tms.entity.response.AdminUserMap;
import com.dsl.tms.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RefreshScope
@RestController
@RequestMapping(path = "/admin")
@CrossOrigin("http://localhost:8080")
public class AdminController {

    @Autowired
    AdminService adminService;

    @RequestMapping(path = "/login",method = RequestMethod.POST)
    public @ResponseBody AdminTokenMap login(@RequestBody AdminInfo adminInfo){
        return adminService.login(adminInfo);
    }

    @RequestMapping(path = "/get_info",method = RequestMethod.GET)
    public @ResponseBody AdminUserMap getUserInfo(@RequestParam("token") String token) {
        return adminService.getUserInfo(token);
    }

    @RequestMapping(path = "/logout",method = RequestMethod.POST)
    public @ResponseBody AdminTokenMap logout(@RequestParam("token") String token){
        return adminService.logout(token);
    }





}
